﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace SYS.Web
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.RouteExistingFiles = false;
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            #region 匹配单页面
            routes.MapRoute(
                name: "robots",
                url: "robots.txt",
                defaults: new { controller = "SinglePage", action = "robots",ex=UrlParameter.Optional }
             );
            routes.MapRoute(
               name: "sitemapIndex",
               url: "sitemap/Index.xml",
               defaults: new { controller = "SinglePage", action = "sitemapIndex" }
            );
            routes.MapRoute(
                name: "sitemap",
                url: "sitemap/{id}.xml",
                defaults: new { controller = "SinglePage", action = "sitemap", id = UrlParameter.Optional }
             );
            #endregion
            routes.MapRoute(
                name: "item_details1",
                url: "g/{itemid}",
                defaults: new { controller = "TaoBao", action = "g", itemid = UrlParameter.Optional }
             );

            routes.MapRoute(
                name: "item_details",
                url: "g/{itemid}.html",
                defaults: new { controller = "TaoBao", action = "g", itemid = UrlParameter.Optional }
                );
           routes.MapRoute(
                name: "search",
                url: "s/{keyword}.html",
                defaults: new { controller = "TaoBao", action = "s", keyword = UrlParameter.Optional, pageno = UrlParameter.Optional }
            );

            routes.MapRoute(
             name: "search2",
             url: "s/{keyword}",
             defaults: new { controller = "TaoBao", action = "s", keyword = UrlParameter.Optional, pageno = UrlParameter.Optional }
             );
            routes.MapRoute(
               name: "search1",
               url: "s/{keyword}/{pageno}.html",
               defaults: new { controller = "TaoBao", action = "s", keyword = UrlParameter.Optional, pageno = UrlParameter.Optional }
               );
            routes.MapRoute(
               name: "item_list",
               url: "{site}/{kid}.html",
               defaults: new { controller = "TaoBao", action = "Index", kid = UrlParameter.Optional, pageno = UrlParameter.Optional }
           );
            routes.MapRoute(
                name: "item_list2",
                url: "{site}/{kid}",
                defaults: new { controller = "TaoBao", action = "Index", kid = UrlParameter.Optional, pageno = UrlParameter.Optional }
                );
            routes.MapRoute(
                name: "item_list1",
                url: "{site}/{kid}/{pageno}.html",
                defaults: new { controller = "TaoBao", action = "Index", kid = UrlParameter.Optional, pageno = UrlParameter.Optional }
                );
            routes.MapRoute("Default1", "{controller}/{action}/{id}.html", new { controller = "home", action = "index", id = "" });
            routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "home", action = "index", id = "" });
        }
    }
}